$(document).ready(function(){
	$('#grid_admin').datagrid({ 
		url:"findUserInfoList.html",
		fit:true,
		fitColumns:true, 
		singleSelect:true,
		pageSize:10,   
	    pageNumber:1,
		columns:[[
			{field:'adminId',title:'用户id',width:60,resizable:false,align:'center'}, 
			{field:'adminName',title:'用户名',width:120,resizable:false,align:'center'},
			{field:'password',title:'密码',width:120,resizable:false,align:'center'},
			{field:'option',title:'操作',width:60,resizable:false,align:'center',
				formatter:function(value,rowData){
		        return "<a  style='font-size:normal;color:#cc0000;cursor:pointer;' onClick=doDelete('"+rowData.adminId+"')>【删除】</a>&nbsp;"+
		        "<a  style='font-size:normal;color:#cc0000;cursor:pointer;' onClick=doUpdate('"+rowData.adminId+"')>【修改】</a>&nbsp;";
					}
			}]],
		toolbar:'#toolbar',
		pagination:true,
	}); 
});
/**
 * 删除问答信息
 */
function doDelete(id){
        $.messager.confirm('提示信息', "您确认删除吗？", function(rf) {
            if(rf){
            	$.ajax({
            		   type: "POST",
            		   url: "deleteAdminInfo.html",
            		   data: {id:id},
            		   success: function(r){
            			   $.messager.alert('提示信息',r.msg,"", function () {
            				   window.location.reload();
            			   });
            		   }
            		});
            }
        });            
}

/**
* 查询功能
*/
function doSearch(){
	//更新查询条件
	$('#grid_admin').datagrid({
			pageNumber:1,
			queryParams:{adminName:$("#adminName").val()}
	});
}

/** 查询输入框回车事件 */
function onEnter(){
   if(event.keyCode == 13){
   	doSearch();
	}
}
function doUpdate(adminId){
	window.location.replace('initAdminUpdate.html?adminId='+adminId);
}
